<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
define("PRIMARY_KEY","nobkt");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_report_vndstmt.php";
$FileTemplate  = "ais_report_vndstmt_list.html";
$TableName     = "ais_hutang";
$SubHeaderTitle= "Statement - Account Payable";
$PageSize      = 10;
$HTMLGridList  = "StatementVendor";

//************ FORM ACTION **************
$periodYear  = GetParam("y","");
$periodMonth = GetParam("m","");
$vendorID  = GetParam("vendorID","");

//******* SHOW FORM CONTENT *********
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);

$TBS->MergeBlock("officeformblk",$DBConnection->GetConnection1(),"SELECT * FROM tblkantor");
$SQL = "SELECT * FROM tblcoa WHERE (".GetAgingAPCondition().") AND tipe=0 ORDER BY skada";
$TBS->MergeBlock("fromskadaformblk",$DBConnection->GetConnection1(),$SQL);
$TBS->MergeBlock("toskadaformblk",$DBConnection->GetConnection1(),$SQL);
$SQLCur = "SELECT * FROM tblcurrency";
$TBS->MergeBlock("currblk",$DBMysql,$SQLCur);
$TBS->MergeBlock("monthformblk",GetArrayMonth());
$TBS->MergeBlock("yearformblk",GetArrayYear());
$TBS->Show();

function GetAgingAPCondition() {
	global $DBConnection;
	$SQL = "SELECT apaging FROM tblprofile WHERE ktrasl='".GetOfficeID()."' ";
	$APAging = $DBConnection->dbc->get_var($SQL);
	$APAgingRow = explode(" ",$APAging);
	foreach ($APAgingRow as $skada) {
		if (strlen($Condition))
			$Condition .= " OR skada like '$skada%' ";
		else
			$Condition = " skada like '$skada%' ";
	}
	return $Condition;
}

?>